package ControlLayer;
import java.util.ArrayList;

import ModelLayer.*;



public class ProductCtr
{
  
    private Product product;
    private ProductList productList;
    private Discount discount;
    private DiscountList discountList;

    
    public ProductCtr()
    {
       productList = ProductList.getInstance();
       discountList = DiscountList.getInstance();
    }
    
    public void createProduct(String productName, int inStock, double price, int id)
    {
       product = new Product(productName, inStock, price, id);
       productList = ProductList.getInstance();
       productList.addProduct(product);
       
    }
    
    public void deleteProduct(int id)
    {
        productList.deleteProduct(id);
    }
    
    public int getProductIdByName(String productName)
    {
    	productList.findProductName(productName);
    	return product.getId();
    }
    
    public void setProductName(String productName, int id)
    {
        productList.findProduct(id).setProductName(productName);
    }
    
    public void setAmointInStock(int inStock,int id)
    {
        productList.findProduct(id).setInStock(inStock);
    }
    
    public void setProductPrice(double price, int id)
    {
        productList.findProduct(id).setPrice(price);
    }
    
    public void addProductDiscount(int id,long discountId)
    {
        Discount discount = discountList.findDiscount(discountId);
        productList.findProduct(id).setDiscount(discount);
    }
    
    public long getProductId(int id)
    {
        return productList.findProduct(id).getId();
    }
    
    public String getProductName(int id)
    {
        return productList.findProduct(id).getProductName();
    }
    
    public double getProductPrice(int id)
    {
        return productList.findProduct(id).getPrice();
    }
    
    public double getAmountofProductsInStock(int id)
    {
        return productList.findProduct(id).getInStock();
    }
}
